 use "$data\women_analysis.dta", clear
 
 tab ITTanalysis, gen(treatment)
 rename treatment1 control
 rename treatment2 treated
 lab var control "dummy for control women"
 lab var treated "dummy for treated women"
 bysort HHID: gen HHIDrepeat=_N
 lab var HHIDrepeat "no. of learners in a HH"
 sort HHIDrepeat
 unique HHID if HHIDrepeat>1
 replace treated=2 if treated==0
 sort HHID treated
 bysort HHID: replace treated=treated[1]
 replace treated=0 if treated==2
 replace control=2 if control==0
 sort HHID control
 bysort HHID: replace control=control[1]
 replace control=0 if control==2
 egen treatcontrolsameHH=rowtotal(treated control)
 lab var treatcontrolsameHH "HHs with and w/o mixed treatment status women"
 lab define treatcontrol 1 "HHs w/o mixed status" 2 "HHs with mixed status"
 lab values treatcontrolsameHH treatcontrol
 unique learnerid if treatcontrolsameHH==2
 unique HHID if treatcontrolsameHH==2
 count if treatcontrolsameHH==2
 
 replace anyhelp=0 if pid_helpedinhome=="T"
 gen tutor=0 if anyhelp!=.
 replace tutor=1 if pid_helpedinhome=="T"
 
 global controlwoman mbase_ageyears  fdstotal rantime ranerror numberkids
 global controlhh land members adults mbase_electrified  mbase_OB mbase_scheduled

 estimates clear
 ****Table B.6 Panel A
 foreach i in dohome_day dohome_week remind_day remind_week talkteach_day talkteach_week{
 ivregress 2sls `i' (participatedTA_IV=ITTanalysis) i.strata $controlwoman $controlhh if treatcontrolsameHH==1 & sequence==1, vce(robust)
 est store `i'
 su `i' if ITTanalysis==0 & treatcontrolsameHH==1 & sequence==1
 estadd scalar controlmean=`r(mean)'
 }
 
 
 ***Table B.6 Panel B
 foreach i in cover treatwater washhands kidchat consultnurse_day consultnurse_week consultnurse_month consultnurse_6months{
 ivregress 2sls `i' (participatedTA_IV=ITTanalysis) i.strata $controlwoman $controlhh if treatcontrolsameHH==1 & sequence==1, vce(robust)
 est store `i'
 su `i' if ITTanalysis==0 & treatcontrolsameHH==1 & sequence==1
 estadd scalar controlmean=`r(mean)'
 }
 
 esttab * using "$results/TableB6.xls",stat(controlmean N r2) keep(participatedTA_IV) b(2) se(2) replace

 
 
 
 
 
 
